package com.github.llyb120.calengine.rule;

import com.github.llyb120.performance.define.Dataset;
import com.github.llyb120.performance.define.Quota;
import groovy.lang.Closure;
import lombok.SneakyThrows;

public class QuotaWrapper extends Quota {

    private RuleEngine ruleEngine;
    private Quota innerObject;

    public QuotaWrapper(RuleEngine ruleEngine, Quota dataset) {
        this.ruleEngine = ruleEngine;
        this.innerObject = dataset;
    }

    @SneakyThrows
    public Object calculate(Object... args) {
        return getCalculate().call(args);
    }

    @Override
    public String getName() {
        return innerObject.getName();
    }

    @Override
    public void setName(String name) {
        innerObject.setName(name);
    }

    @Override
    public Closure getCalculate() {
        return innerObject.getCalculate();
    }

    @Override
    public void setCalculate(Closure calculate) {
        innerObject.setCalculate(calculate);
    }
}
